package com.ehotting.edsta.circuitDesign.enums;

public enum CircuitTypeEnum implements BaseEnum {

    SENSOR(0,"sensor","数据采集电路模块"),
    CONTROLLER(1,"controller","数据处理电路模块"),
    POWER(2,"power","电源电路模块"),
    PCB(3,"pcb","pcb电路模块"),
    USER(-1,"user","其他模块");

    private Integer value;
    private String code;
    private String name;

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    CircuitTypeEnum(Integer value,String code, String name) {
        this.value = value;
        this.code = code;
        this.name = name;
    }


    public static CircuitTypeEnum getObject(Integer value){
        CircuitTypeEnum[] rules = CircuitTypeEnum.values();
        for(CircuitTypeEnum rule : rules){
            if(rule.getValue().equals(value)){
                return rule;
            }
        }
        return CircuitTypeEnum.SENSOR;
    }

    public static CircuitTypeEnum getByCode(String code){
        CircuitTypeEnum[] rules = CircuitTypeEnum.values();
        for(CircuitTypeEnum rule : rules){
            if(rule.getCode().contains(code)){
                return rule;
            }
        }
        return CircuitTypeEnum.SENSOR;
    }

}
